package com.cloud.controller;

import com.cloud.dto.ProjectDto;
import com.cloud.dto.TeamDto;
import com.cloud.dto.UserDto;
import com.cloud.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("Admin")
public class AdminController {
    @Autowired
    AdminService adminService;

    @GetMapping("/getUserById/{id}")
    public Map getUserById(@PathVariable("id") Integer userId){
        Map map=new HashMap();
        UserDto userDto=adminService.findUserById(userId);
        map.put("userbyid",userDto);
        return map;
    }

    @GetMapping("/getUserByName/{name}")
    public Map getUserByName(@PathVariable("name") String userName){
        Map map=new HashMap();
        List<UserDto> userDtoList=adminService.findUserByName(userName);
        map.put("userbyname",userDtoList);
        return map;
    }

    @GetMapping("/getTeamById/{id}")
    public Map getTeamById(@PathVariable("id") Integer teamId){
        Map map=new HashMap();
        TeamDto teamDto=adminService.findTeamById(teamId);
        map.put("teambyid",teamDto);
        return map;
    }

    @GetMapping("/getTeamByName/{name}")
    public Map getTeamByName(@PathVariable("name") String teamName){
        Map map=new HashMap();
        TeamDto teamDto=adminService.findTeamByName(teamName);
        map.put("teambyname",teamDto);
        return map;
    }

    @GetMapping("/getProById/{id}")
    public Map getProById(@PathVariable("id") Integer projectId){
        Map map=new HashMap();
        ProjectDto projectDto=adminService.findProById(projectId);
        map.put("probyid",projectDto);
        return map;
    }

    @GetMapping("/getProByName/{name}")
    public Map getProByName(@PathVariable("name") String projectName){
        Map map=new HashMap();
        List<ProjectDto> projectDtoList=adminService.findProByName(projectName);
        map.put("probyname",projectDtoList);
        return map;
    }
}
